<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" pageEncoding="utf-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript" src="client/lib/jquery-1.9.1.min.js"></script>

<script type="text/javascript">
	function init(){
		
	    $.ajax({
	        url: "client/service/loginController/initLoginUserName",
	        data: 'username=' + $("#username").val() + "&password=" + $("#password").val()+"&loginCheckbox="+
	        $('input[name="loginCheckbox"]:checked').length,
	        type: 'post',
	        dataType: 'json',
	        success: function(msg){
	        	if(msg.success == true&& msg.result!= undefined){
	        		document.getElementById('username').value = msg.result.split('-_-')[0]
	        		document.getElementById('password').value = msg.result.split('-_-')[1]
	           	}
	        },
	        error: function(){
	        	var error=document.getElementById('login_error');
	        	error.innerText='用户名或密码不正确，请重新输入';
	        	error.style.display='block';
	            $("#username").focus();
		        loginStatusReset();
	        }
	    });
		
		//网页内按下回车触发
		document.onkeyup=function(){
		    if(event.keyCode==13)
		    {
		    	login();
		        return false;                               
		    }
		}
	}
    function login(){
      	var error=document.getElementById('login_error');
        error.style.display='none';
        if($("#username").val() == ""){
            error.innerText='*请输入用户名!';
            error.style.display='block';
	        $("#username").focus();
	        return;
	    }
	    if($("#password").val()==""){
        	error.innerText='*请输入密码!';
        	error.style.display='block';
	        $("#password").focus();
	        return;
	    }
	    
	    var userType=$("#userType").val();
	    var sUrl="client/service/loginController/queryLoginUser";
	    var sIndexUrl="client/index.jsp";
	   /* 
	    if (userType=="5" ||userType=="普通用户"){
	        sUrl="client/service/clientUserController/queryAdminUser";
	        sIndexUrl="client/index.jsp";
	    }*/
	    
	    loginStatus();
	    $.ajax({
	        url: sUrl,
	        data: 'username=' + $("#username").val() + "&password=" + $("#password").val()+"&loginCheckbox="+
	        $('input[name="loginCheckbox"]:checked').length,
	        type: 'post',
	        dataType: 'json',
	        success: function(msg){
	        	if(msg.result == "success"){ 
	        		location.href=sIndexUrl; 
	        	    
	           	}
	        	else if(msg.result == "wrongIn"){
		        	var error=document.getElementById('login_error');
		        	error.innerText='调用登录接口失败,请重试!';
		        	error.style.display='block';
	                $("#username").focus();
	    	        loginStatusReset();
	        	}else{
		        	var error=document.getElementById('login_error');
		        	error.innerText='用户名或密码不正确，请重新输入';
		        	error.style.display='block';
	                $("#username").focus();
	    	        loginStatusReset();
	        	}
	        },
	        error: function(){
	        	var error=document.getElementById('login_error');
	        	error.innerText='*登录异常';
	        	error.style.display='block';
	            $("#username").focus();
		        loginStatusReset();
	        }
	    });
    }
    function loginStatus(){
    	var submit=document.getElementById('sumbit');
    	submit.innerText="加载中...";
    	submit.style.letterSpacing="0px";
    }
    function loginStatusReset(){
    	var submit=document.getElementById('sumbit');
    	submit.innerText="登录";
    	submit.style.letterSpacing="15px";
    }
</script>

<title>时代地产GIS平台</title>
<style type="text/css">
	html,body{
	    background-color: #ffffff;
	    width:100%;
	    height:100%;
	    margin:0px;
	    padding:0px;
   		font-family: "Microsoft YaHei";
	}
	html,body{
	  background-image: -moz-linear-gradient( 90deg, rgb(89,127,241) 0%, rgb(97,197,239) 100%);
	  background-image: -webkit-linear-gradient( 90deg, rgb(89,127,241) 0%, rgb(97,197,239) 100%);
	  background-image: -ms-linear-gradient( 90deg, rgb(89,127,241) 0%, rgb(97,197,239) 100%);
	}

		.login_top{width:100%;height:100px;background-color:#ef4531;}
	.login_top .login_title{width:1280px;height:100%;margin:auto;background:url(images/login/gislogo.png) no-repeat;}
	.login_center{width:100%;height:calc(100% - 160px);}
	.login_center .login_form{width:1280px; height:65%;%;margin-left:calc((100% - 1280px)/2);background:url(images/login/bg.png) no-repeat;background-origin:content-box;background-position:left center;}
	.login_center .login_form>div{width:425px;height:328px;background-color:#9ecff8;float:right;position:relative;top: 57%;
    right: 37%;margin-top:-185px;-webkit-box-shadow:0px 0px 10px #A9A9A9;-moz-box-shadow:0px 0px 10px #A9A9A9;box-shadow:0px 0px 10px #A9A9A9;border-radius: 6px;-webkit-border-radius: 6px;-moz-border-radius: 6px;}
	.login_center .login_form input {width:283px;height:30px;line-height:30px;font-size:14px;padding-left:15px;}
	.login_center .login_form .login_usertype{height:34px;width:300px;margin:auto;background:url(images/login/usertype.png) no-repeat;padding-left:55px;margin-top:50px;}
	.login_center .login_form .login_usertype select{width:300px;height:34px;font-size:14px;padding-left:15px;}
	.login_center .login_form .login_user{    height: 46px;
    width: 330px;margin:auto;background:url(images/login/username.png) no-repeat;padding-left:55px;margin-top:70px;}
	.login_center .login_form .login_password{height: 66px;
    width: 333px;margin:auto;background:url(images/login/password.png) no-repeat;padding-left:55px;margin-top:30px;}
	.login_center .login_form .login_button{position:absolute;bottom:60px;width:100%;}
	.login_center .login_form #login_error{width:300px;padding-left:55px;margin: -21px -61px 11px auto;;color:red;display:none;}
	.login_center .login_form #sumbit{width:105px;height:34px;line-height:34px;background-color:#ef4531;color:#fff;text-align:center;margin:auto;letter-spacing:15px;padding-left:15px;cursor:pointer;}
	.login_center .login_form #sumbit:hover{background-color:#053f92;}
		.login_bottom .login_foot{            margin-top: -113px;margin-left: 10%;height: 435px;;line-height:60px;font-size:16px;color:#ffffff;text-align:center; background:url(images/login/loginbg.png) no-repeat;}
	.login_logo{    height: 107px; background:url(images/login/logo.png) no-repeat;}
	.login_center .login_form .login_checkbox{      width: 24px;margin-top: -24px;margin-left: 72px;}
    .checklabel{margin-top: -30px;margin-left: 99px;}
</style>
</head>
<body onload="init()">
	 
	<div class="login_center">
	<div class="login_logo"> </div> 
		<div class="login_form">
			<div>
			       
				<!-- 
				<div class="login_usertype"><select id="userType" onchange="document.getElementById('username').value='';document.getElementById('password').value='';"><option value='0'>管理员</option><option value='5'>普通用户</option></select></div>
				 -->
				<div class="login_user"><input type="text" id="username" name="username" value="" placeholder="用户名" onkeyup='document.getElementById("login_error").style.display="none"'/></div>
				<div class="login_password"><input type="password" name="password" id="password" value="" placeholder="密码" onkeyup='document.getElementById("login_error").style.display="none"'/></div>
				<input type="checkbox" class="login_checkbox" name="loginCheckbox" id="loginCheckbox" checked="checked" placeholder="记住用户名" /><div class="checklabel">记住用户名</div>
				<div id="login_error">*用户名和密码错误！</div>
				<div class="login_button" onclick="login()"><div id="sumbit">登录</div></div>
				
			</div>
		</div>
		<div class="login_bottom"><div class="login_foot"> </div></div>
	</div>
	
</body>
</html>

